-----------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  D:\Ellen\Dropbox\Pajaro_AgInnovation\Submission\JAERE\Replication_Code\Log\L
> and_event_study_log.log
  log type:  text
 opened on:  29 Nov 2023, 14:13:30

. 
. use "Data\Land_clean_20230615.dta", clear

. 
. sort year quarter

. 
. ********************************************************************************
. *1. ANNUAL EVENT STUDY: RAW DATA 
. ********************************************************************************
. 
. *Balance the panel
. bysort parcelnum: gen ntime = [_N]

. sum ntime

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       ntime |      7,709    10.66766    1.268176          1         11

. keep if ntime==`r(max)'
(669 observations deleted)

. 
. ********************************************************************************
. *1.1 Generate dummy variables
. ********************************************************************************
. 
. *Generate event periods 
. gen event_time = 0

. forvalues j = 1/11 {
  2. replace event_time = -`j' if year == 2012 - `j'
  3. replace event_time = `j' if year == 2012 + `j'
  4. }
(640 real changes made)
(640 real changes made)
(0 real changes made)
(640 real changes made)
(640 real changes made)
(640 real changes made)
(0 real changes made)
(640 real changes made)
(0 real changes made)
(640 real changes made)
(0 real changes made)
(640 real changes made)
(0 real changes made)
(640 real changes made)
(0 real changes made)
(640 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. 
. 
. *Generate pre period interaction terms
. forvalues j = 1/3 {
  2. gen minus`j' = 0
  3. replace minus`j' = 1 if inside == 1 & event_time == -`j'
  4. }
(71 real changes made)
(0 real changes made)
(71 real changes made)

. 
. *Generate post period interaction terms
. forvalues j = 1/9 {
  2. gen plus`j' = 0
  3. replace plus`j' = 1 if inside == 1 & event_time == `j'
  4. }
(70 real changes made)
(70 real changes made)
(70 real changes made)
(70 real changes made)
(70 real changes made)
(70 real changes made)
(70 real changes made)
(70 real changes made)
(0 real changes made)

. 
. *Generate treatment event interaction
. generate event_treatment = 0

. replace event_treatment  = 1 if inside == 1 & event_time==0
(70 real changes made)

. 
. 
. *Drop missing variables
. foreach var of varlist plus* minus* {
  2. summ `var'
  3.    if `r(sum)' == 0  {
  4.             drop `var'
  5.            }
  6.        else { 
  7.                }
  8.          }

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus1 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus2 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus3 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus4 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus5 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus6 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus7 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus8 |      7,040    .0099432    .0992256          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       plus9 |      7,040           0           0          0          0

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      minus1 |      7,040    .0100852    .0999246          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      minus2 |      7,040           0           0          0          0

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      minus3 |      7,040    .0100852    .0999246          0          1

. 
. 
. *UNCONDITIONAL EVENT STUDY - TOTAL AG LAND
. preserve

. xtreg acres_agtot plus* i.year#i.county event_treatment i.inside minus3 minus1, fe clus
> ter(parcelnum)
note: plus7 omitted because of collinearity
note: plus8 omitted because of collinearity
note: 2018.year#2.county_code omitted because of collinearity
note: minus1 omitted because of collinearity

Fixed-effects (within) regression               Number of obs     =      5,266
Group variable: parcelnum                       Number of groups  =        616

R-sq:                                           Obs per group:
     within  = 0.0597                                         min =          1
     between = 0.0465                                         avg =        8.5
     overall = 0.0487                                         max =          9

                                                F(24,615)         =          .
corr(u_i, Xb)  = -0.1874                        Prob > F          =          .

                                (Std. Err. adjusted for 616 clusters in parcelnum)
----------------------------------------------------------------------------------
                 |               Robust
     acres_agtot |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-----------------+----------------------------------------------------------------
           plus1 |   .4979218   .4219165     1.18   0.238      -.33065    1.326494
           plus2 |   .1272387   .7577531     0.17   0.867    -1.360859    1.615336
           plus3 |  -1.619796   .7350257    -2.20   0.028    -3.063261   -.1763314
           plus4 |  -.4303795    .743532    -0.58   0.563    -1.890549     1.02979
           plus5 |   .2200356   .6224332     0.35   0.724    -1.002317    1.442388
           plus6 |   .2077679    .623033     0.33   0.739    -1.015762    1.431298
           plus7 |          0  (omitted)
           plus8 |          0  (omitted)
                 |
year#county_code |
         2009 2  |   .2441509   .2144025     1.14   0.255    -.1768989    .6652007
         2011 1  |   .0756322   .3214513     0.24   0.814    -.5556431    .7069074
         2011 2  |   .4279996   .1880895     2.28   0.023     .0586239    .7973752
         2012 1  |   .0410186    .320679     0.13   0.898      -.58874    .6707772
         2012 2  |   .6008687   .2330539     2.58   0.010     .1431908    1.058547
         2013 1  |   .1527562   .5830844     0.26   0.793    -.9923217    1.297834
         2013 2  |   .5342733   .1496126     3.57   0.000     .2404598    .8280868
         2014 1  |  -.1288695    .642199    -0.20   0.841    -1.390038    1.132299
         2014 2  |   .3388383   .1193968     2.84   0.005     .1043634    .5733132
         2015 1  |   1.915582   .8039355     2.38   0.017     .3367906    3.494374
         2015 2  |   1.954438    .293408     6.66   0.000     1.378235    2.530641
         2016 1  |   .2560724   .8244786     0.31   0.756    -1.363062    1.875207
         2016 2  |   .9941358   .3741379     2.66   0.008     .2593929    1.728879
         2017 1  |  -.8358875   .6896563    -1.21   0.226    -2.190254    .5184795
         2017 2  |   .0987233   .0604317     1.63   0.103    -.0199541    .2174008
         2018 1  |  -.7881071   .6913752    -1.14   0.255     -2.14585    .5696355
         2018 2  |          0  (omitted)
                 |
 event_treatment |   .1439597   .1846314     0.78   0.436    -.2186247    .5065441
        1.inside |    45.6138   .2625283   173.75   0.000     45.09824    46.12936
          minus3 |   .4800977   .4594567     1.04   0.296    -.4221965    1.382392
          minus1 |          0  (omitted)
           _cons |   24.85495   .1525415   162.94   0.000     24.55539    25.15452
-----------------+----------------------------------------------------------------
         sigma_u |  34.746569
         sigma_e |  4.1854942
             rho |  .98569746   (fraction of variance due to u_i)
----------------------------------------------------------------------------------

. mat coeff = [  _b[minus3] \ _b[minus1] \ _b[event_treatment] \ _b[plus1] \ _b[plus2] //
> /
>                          \ _b[plus3] \ _b[plus4] \_b[plus5] \_b[plus6] \ _b[plus7] \ _b
> [plus8] ]                

. mat se = [ _se[minus3] \ _se[minus1]  \ _se[event_treatment] \ _se[plus1] \ _se[plus2] 
> \ _se[plus3] ///
> \ _se[plus4] \_se[plus5] \_se[plus6] \_se[plus7] \_se[plus8] ]

. mat upper=coeff+((1.96)*se)

. mat lower=coeff-((1.96)*se)

. mat x=(-3\-1\0\1\2\3\4\5\6\7\8)

. mat data=[coeff,upper,lower,x]

. svmat data

. rename data1 coeff

. rename data2 upper

. rename data3 lower

. rename data4 x

. 
. matrix colnames data=beta loCI highCI year

. matrix list data

data[11,4]
           beta        loCI      highCI        year
 r1    .4800977   1.3806328  -.42043736          -3
 r2           0           0           0          -1
 r3   .14395967   .50583714   -.2179178           0
 r4   .49792181   1.3248782  -.32903458           1
 r5   .12723867   1.6124348  -1.3579575           2
 r6  -1.6197961  -.17914571  -3.0604466           3
 r7  -.43037953   1.0269431  -1.8877022           4
 r8   .22003561   1.4400047  -.99993348           5
 r9   .20776787   1.4289126  -1.0133769           6
r10           0           0           0           7
r11           0           0           0           8

. putexcel set "Tables\land_eventstudy_cy_$outputdate.xlsx", sheet(agtotal) replace
Note: file will be replaced when the first putexcel command is issued

. putexcel A1 = matrix(data)
file Tables\land_eventstudy_cy_20231125.xlsx saved

. clear

. svmat data, names(col)
number of observations will be reset to 11
Press any key to continue, or Break to abort
number of observations (_N) was 0, now 11

. 
. replace year = 2009 if year ==-3
(1 real change made)

. replace year = 2010 if year ==-2
(0 real changes made)

. replace year = 2011 if year ==-1
(1 real change made)

. replace year = 2012 if year ==0
(1 real change made)

. replace year = 2013 if year ==1
(1 real change made)

. replace year = 2014 if year ==2
(1 real change made)

. replace year = 2015 if year ==3
(1 real change made)

. replace year = 2016 if year ==4
(1 real change made)

. replace year = 2017 if year ==5
(1 real change made)

. replace year = 2018 if year ==6
(1 real change made)

. replace year = 2019 if year ==7
(1 real change made)

. replace year = 2020 if year ==8
(1 real change made)

. 
. 
. twoway (rcap loCI highCI year if year <2016) (scatter beta year if year <2016, msymbol(
> triangle) msize(small)) if year>2010 , ///
> ytitle(Agricultural Land (Acres) )  ///
>  scheme(s1color) legend(label (1 95% CI) label (2 Difference Inside and Outside)) ///
>         xtitle(Year) yline(0, lcolor(black)) xlab(2011(1)2015) ylab(-6(2)6)

. 
. graph save "Figures\ES_agtotal_cy_$outputdate.gph", replace
(file Figures\ES_agtotal_cy_20231125.gph saved)

. graph export "Figures\ES_agtotal_cy_$outputdate.png", replace
(file Figures\ES_agtotal_cy_20231125.png written in PNG format)

. restore

. 
. 
. 
. *UNCONDITIONAL EVENT STUDY - VEG + STRAW 
. preserve

. 
. xtreg vegstraw plus* i.year#i.county event_treatment i.inside minus3 minus1, fe cluster
> (parcelnum)
note: plus7 omitted because of collinearity
note: plus8 omitted because of collinearity
note: 2018.year#2.county_code omitted because of collinearity
note: minus1 omitted because of collinearity

Fixed-effects (within) regression               Number of obs     =      5,266
Group variable: parcelnum                       Number of groups  =        616

R-sq:                                           Obs per group:
     within  = 0.0270                                         min =          1
     between = 0.1091                                         avg =        8.5
     overall = 0.0773                                         max =          9

                                                F(24,615)         =          .
corr(u_i, Xb)  = 0.2169                         Prob > F          =          .

                                (Std. Err. adjusted for 616 clusters in parcelnum)
----------------------------------------------------------------------------------
                 |               Robust
        vegstraw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-----------------+----------------------------------------------------------------
           plus1 |   4.420915   2.019889     2.19   0.029     .4541989    8.387632
           plus2 |   5.425923   2.361596     2.30   0.022     .7881533    10.06369
           plus3 |   6.306597   2.161311     2.92   0.004     2.062152    10.55104
           plus4 |   2.478728   2.476215     1.00   0.317    -2.384135    7.341591
           plus5 |   -.100117    3.05043    -0.03   0.974    -6.090638    5.890404
           plus6 |   1.555732   1.967834     0.79   0.429    -2.308757    5.420221
           plus7 |          0  (omitted)
           plus8 |          0  (omitted)
                 |
year#county_code |
         2009 2  |  -.2365088   .8324613    -0.28   0.776     -1.87132    1.398303
         2011 1  |   2.731045   1.109696     2.46   0.014     .5517914    4.910298
         2011 2  |   1.168597   .6752822     1.73   0.084    -.1575419    2.494735
         2012 1  |   1.754362   1.310553     1.34   0.181    -.8193398    4.328064
         2012 2  |  -.1340847   .7088517    -0.19   0.850    -1.526148    1.257979
         2013 1  |   1.904386   1.188673     1.60   0.110    -.4299646    4.238736
         2013 2  |  -.4697654   .7613302    -0.62   0.537    -1.964888    1.025357
         2014 1  |   1.217194   1.059588     1.15   0.251    -.8636551    3.298044
         2014 2  |   .2503844   .6773328     0.37   0.712    -1.079781     1.58055
         2015 1  |   .5284777   1.181678     0.45   0.655    -1.792136    2.849091
         2015 2  |   .3756571   .6178035     0.61   0.543    -.8376032    1.588917
         2016 1  |   .8914064   1.220142     0.73   0.465    -1.504743    3.287556
         2016 2  |   .2441648   .6334339     0.39   0.700     -.999791    1.488121
         2017 1  |   .3872588   1.405725     0.28   0.783    -2.373344    3.147862
         2017 2  |   .0687891   .6124461     0.11   0.911     -1.13395    1.271528
         2018 1  |   1.026017   1.381773     0.74   0.458    -1.687548    3.739582
         2018 2  |          0  (omitted)
                 |
 event_treatment |   4.135139   2.567041     1.61   0.108    -.9060912    9.176368
        1.inside |   3.680194   1.737041     2.12   0.035     .2689428    7.091445
          minus3 |   -8.19672   3.417687    -2.40   0.017    -14.90847   -1.484968
          minus1 |          0  (omitted)
           _cons |   16.31416   .4673566    34.91   0.000     15.39635    17.23197
-----------------+----------------------------------------------------------------
         sigma_u |   30.66653
         sigma_e |    9.94284
             rho |  .90487786   (fraction of variance due to u_i)
----------------------------------------------------------------------------------

. mat coeff1 = [  _b[minus3] \ _b[minus1] \ _b[event_treatment] \ _b[plus1] \ _b[plus2] \
>  _b[plus3] ///
>                         \ _b[plus4] \_b[plus5] \_b[plus6] \_b[plus7] \_b[plus8] ]      
>          

. mat se1 = [ _se[minus3] \ _se[minus1] \ _se[event_treatment] \ _se[plus1] \ _se[plus2] 
> ///
> \ _se[plus3] \ _se[plus4] \_se[plus5] \_se[plus6] \_se[plus7] \_se[plus8] ]

. mat upper1=coeff1+((1.96)*se1)

. mat lower1=coeff1-((1.96)*se1)

. mat x=(-3\-1\0\1\2\3\4\5\6\7\8)

. 
. reg otherag plus* event_treatment i.inside minus3 minus1 ,cluster(parcelnum)
note: plus7 omitted because of collinearity
note: plus8 omitted because of collinearity
note: minus1 omitted because of collinearity

Linear regression                               Number of obs     =      5,266
                                                F(9, 615)         =      14.90
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0243
                                                Root MSE          =     17.726

                               (Std. Err. adjusted for 616 clusters in parcelnum)
---------------------------------------------------------------------------------
                |               Robust
        otherag |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
----------------+----------------------------------------------------------------
          plus1 |   .3609482   .9544342     0.38   0.705    -1.513397    2.235294
          plus2 |  -.9557734   1.223638    -0.78   0.435    -3.358789    1.447242
          plus3 |  -1.031965   1.117245    -0.92   0.356    -3.226043    1.162113
          plus4 |  -1.364339   1.218535    -1.12   0.263    -3.757334    1.028656
          plus5 |  -1.770825   1.172975    -1.51   0.132    -4.074346     .532697
          plus6 |  -2.271903   1.092514    -2.08   0.038    -4.417413   -.1263928
          plus7 |          0  (omitted)
          plus8 |          0  (omitted)
event_treatment |  -1.169766   .8268484    -1.41   0.158    -2.793555    .4540222
       1.inside |  -8.160453   1.487719    -5.49   0.000    -11.08208   -5.238829
         minus3 |   4.273273   1.776925     2.40   0.016     .7836961     7.76285
         minus1 |          0  (omitted)
          _cons |   11.55556   .7313216    15.80   0.000     10.11937    12.99175
---------------------------------------------------------------------------------

. mat coeff2 = [   _b[minus3] \ _b[minus1] \ _b[event_treatment] \ _b[plus1] \ _b[plus2] 
> \ _b[plus3] ///
>                          \ _b[plus4] \_b[plus5]  \_b[plus6] \_b[plus7] \_b[plus8] ]    
>                  

. mat se2 = [ _se[minus3] \ _se[minus1] \ _se[event_treatment] \ _se[plus1] \ _se[plus2] 
> ///
>  \ _se[plus3] \ _se[plus4] \_se[plus5] \_se[plus6] \_se[plus7] \_se[plus8] ]

. mat upper2=coeff2+((1.96)*se2)

. mat lower2=coeff2-((1.96)*se2)

. mat data=[coeff1,upper1,lower1,x, coeff2, upper2, lower2]

. 
. svmat data

. rename data1 coeff_1

. rename data2 upper_1

. rename data3 lower_1

. rename data4 x

. rename data5 coeff2

. rename data6 upper2

. rename data7 lower2

. 
. matrix colnames data=beta1 loCI1 highCI1 year beta2 loCI2 highCI2

. matrix list data

data[11,7]
          beta1       loCI1     highCI1        year       beta2       loCI2     highCI2
 r1  -8.1967203  -1.4980539  -14.895387          -3   4.2732729   7.7560462   .79049957
 r2           0           0           0          -1           0           0           0
 r3   4.1351387   9.1665398  -.89626246           0  -1.1697665   .45085634  -2.7903892
 r4   4.4209154   8.3798981   .46193263           1   .36094823   2.2316393  -1.5097428
 r5   5.4259234   10.054651   .79719541           2   -.9557734   1.4425574  -3.3541042
 r6   6.3065967   10.542766   2.0704276           3  -1.0319649   1.1578352   -3.221765
 r7   2.4787278   7.3321099  -2.3746542           4  -1.3643392   1.0239902  -3.7526687
 r8  -.10011697   5.8787249  -6.0789589           5  -1.7708246   .52820587  -4.0698551
 r9   1.5557319   5.4126868  -2.3012229           6   -2.271903  -.13057582  -4.4132303
r10           0           0           0           7           0           0           0
r11           0           0           0           8           0           0           0

. putexcel set "Tables\land_eventstudy_cy_$outputdate.xlsx", sheet(crop) modify

. putexcel A1 = matrix(data)
file Tables\land_eventstudy_cy_20231125.xlsx saved

. clear

. svmat data, names(col)
number of observations will be reset to 11
Press any key to continue, or Break to abort
number of observations (_N) was 0, now 11

. 
. replace year = 2009 if year ==-3
(1 real change made)

. replace year = 2010 if year ==-2
(0 real changes made)

. replace year = 2011 if year ==-1
(1 real change made)

. replace year = 2012 if year ==0
(1 real change made)

. replace year = 2013 if year ==1
(1 real change made)

. replace year = 2014 if year ==2
(1 real change made)

. replace year = 2015 if year ==3
(1 real change made)

. replace year = 2016 if year ==4
(1 real change made)

. replace year = 2017 if year ==5
(1 real change made)

. replace year = 2018 if year ==6
(1 real change made)

. replace year = 2019 if year ==7
(1 real change made)

. replace year = 2020 if year ==8
(1 real change made)

. 
. twoway (rcap loCI1 highCI1 year if year <2016) (scatter beta1 year if year <2016) if ye
> ar>2010, ///
> ytitle(Acres) scheme(s1color) xtitle(Year) yline(0, lcolor(black)) xlab(2011(1)2015) yl
> ab(-10(2)10) ///
> legend(label (1 95% CI) label (2 Difference Inside and Outside (Veg + Straw)) label (3 
> 95% CI) label (4 Difference Inside and Outside (Other Ag)))      

. 
. graph save "Figures\ES_vegstraw_cy_$outputdate.gph", replace
(file Figures\ES_vegstraw_cy_20231125.gph saved)

. graph export "Figures\ES_vegstraw_cy_$outputdate.png", replace
(file Figures\ES_vegstraw_cy_20231125.png written in PNG format)

. restore

. 
. log close
      name:  <unnamed>
       log:  D:\Ellen\Dropbox\Pajaro_AgInnovation\Submission\JAERE\Replication_Code\Log\L
> and_event_study_log.log
  log type:  text
 closed on:  29 Nov 2023, 14:13:36
-----------------------------------------------------------------------------------------
